package a_doubleWrite;

import java.util.ArrayList;
import java.util.List;

/**
 * todo
 *
 * @author luolidong
 * @version 1.0
 * @create 2021-08-03 10:52
 */
public class L731 {
    private List<int[]> list;

    public L731() {
        list = new ArrayList<>();
    }

    public boolean book(int start, int end) {
        list.sort((x, y) -> x[0] - y[0]);
        int count=0;
        for (int[] n:list) {
            if(n[1]>start&&n[0]<end){
                count++;
            }
        }
        if(count>2) return false;
        list.add(new int[]{start, end});
        return true;
    }
}
